package com.example.graduation.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author Administrator
 * <p>
 * Swagger配置类
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()// 通过.select()方法，去配置扫描接口,RequestHandlerSelectors配置如何扫描接口
                .apis(RequestHandlerSelectors.basePackage("com.example.graduation.controller"))
                .build();
    }

    /**
     * 配置文档信息
     *
     * @return ApiInfo
     */
    private ApiInfo apiInfo() {
        Contact contact = new Contact("Jeffrey", "https://blog.csdn.net/weixin_48678547", "1010691328@qq.com");
        return new ApiInfo(
                "毕设API测试",
                "",
                "",
                "",
                contact,
                "",
                "",
                new ArrayList<>()
        );
    }
}
